var choosetype = "轻松租车";
$(document).ready(function() {
					pageLoad();
					PageLoadTime();
					requestRent();
					pageChooseTime();
					pageBannerChoose();
					pageBannerjs();
					pageHelpjs();
					requestLineClick();
					requestRentClick();
					requestChinacity();
					requestChinacityinfo("北京");
					rentGoto();
					wantLine("面朝大海");
					wantHotLine();
					wantCity(1);
					clickcity();
					wantBanner();
					gotoLineIndex();
					ChooseRentTime();
					WantHotCity();
					
});
//首页选择时间功能
function ChooseRentTime(){
	laydate.render({
		  elem: '#chooseGotime', //指定元素,
		  min:new Date().Format("yyyy-MM-dd")
	});
	laydate.render({
		  elem: '#chooseBacktime', //指定元素,
		  min:new Date().Format("yyyy-MM-dd")
	});
	$("input.index_choosemode_one_right_time_start_item").focus(function(){
		$("div.index_choosemode_one_right_timechoose").removeClass("hidden");
		$("div.index_choosemode_one_right_timechoose").focus();
		$("div.index_choosemode_one_right_timechoosereturn").addClass("hidden");
		//绑定选择出发时间事件
		for(var i=0;i<47;i++){
			$("div.index_choosemode_one_right_timechoose div.index_choosemode_one_right_timechoose_right_item:eq("+i+")").click(function(i){
				return function(){
					var time = $(this).text();
//					starthour = $(this).data("time");
					$("input.index_choosemode_one_right_time_start_item").val(time);
					$("div.index_choosemode_one_right_timechoose").addClass("hidden");
					CountRentTime();
				}
			}(i))
		};
	});
	$("input.index_choosemode_one_right_time_return_item").focus(function(){
		$("div.index_choosemode_one_right_timechoosereturn").removeClass("hidden");
		$("div.index_choosemode_one_right_timechoosereturn").focus();
		$("div.index_choosemode_one_right_timechoose").addClass("hidden");
		//绑定选择返回时间事件
		for(var i=0;i<47;i++){
			$("div.index_choosemode_one_right_timechoosereturn div.index_choosemode_one_right_timechoose_right_item:eq("+i+")").click(function(i){
				return function(){
					var etime = $(this).text();
//					endhour = $(this).data("time");
					$("input.index_choosemode_one_right_time_return_item").val(etime);
					$("div.index_choosemode_one_right_timechoosereturn").addClass("hidden");
					CountRentTime();
				}
			}(i))
		};
	});
	$("div.index_choosemode_one_right_timechoose").blur(function(){
		$(this).addClass("hidden");
		CountRentTime();
	});
	$("div.index_choosemode_one_right_timechoosereturn").blur(function(){
		$(this).addClass("hidden");
		CountRentTime();
	});
	//只要鼠标移动到选择选择时间区域就会执行计算时间差动作
	$("div.index_choosemode_one").mouseover(function(){
		CountRentTime();
	});
	
}
//计算出发返程时间差
function CountRentTime(){
	var startdate = $("input#chooseGotime").val();
	var enddate = $("input#chooseBacktime").val();
	var starthour = $("input#chooseGohour").val();
	var endhour = $("input#chooseBackhour").val();
	var sd = startdate + " " + starthour + ":00";
	var ed = enddate + " " + endhour + ":00";
	//处理时间
	var stime = new Date(sd);
	var etime = new Date(ed);
	var usedTime = etime - stime;
	var days=Math.floor(usedTime/(24*3600*1000));  
    //计算出小时数  
    var leave1=usedTime%(24*3600*1000);    //计算天数后剩余的毫秒数  
    var hours=Math.floor(leave1/(3600*1000));  
    //计算相差分钟数  
    var leave2=leave1%(3600*1000);        //计算小时数后剩余的毫秒数  
    var minutes=Math.floor(leave2/(60*1000));  
	
	var up = days + "天";
	var down = hours + "小时" + minutes + "分钟";
	$("div.index_choosemode_one_right_time_center_time_up").text(up);
	$("div.index_choosemode_one_right_time_center_time_down").text(down);
	
}
//是否可以跳转判定
function TestGoToList(){
	var startdate = $("input#chooseGotime").val();
	var enddate = $("input#chooseBacktime").val();
	var starttime = $("input.index_choosemode_one_right_time_start_item").val();
	var endtime = $("input.index_choosemode_one_right_time_return_item").val();
	var start = startdate + " " + starttime + ":00";
	var end = enddate + " " + endtime + ":00";
	var sd = new Date(start);
	var ed = new Date(end);
	var now = new Date();
	console.log("start="+start);
	console.log("sd="+sd);
	console.log("end="+end);
	console.log("ed="+ed);
	if(sd >= ed){
		alert("选择开始时间不能大于结束时间！");
		return(0);
	};
	if(sd <= now){
		alert("选择开始时间不能小于现在时间！")
		return(0)
	};
	return(1);		
}
//banner中的搜索跳转
function pageChooseTime(){
	//立即选车跳转
	$("input#chooseTimenow").click(
			function() {
				var test = TestGoToList();
				if(test == 1){
					var startDate = $("#chooseGotime").val();
					var endDate = $("#chooseBacktime").val();
					var rentcity=$("input#chooseGocity").val();
					var starthour = $("input.index_choosemode_one_right_time_start_item").val();
					var endhour = $("input.index_choosemode_one_right_time_return_item").val();
//					var city=encodeURI(rentcity);
					/*window.localStorage.setItem(
							"rentstarttime", startDate);// 将用户选择的出发时间储存在本地储存中，随时取用
					window.localStorage.setItem(
							'rentbacktime', endDate);// 将用户选择的返程时间储存在本地储存中，随时取用
					window.localStorage.setItem('rentcity',rentcity);*/
//					console.log("city="+city);
//					var rentcity = encodeURIComponent(city);
					var url = basePath+"/rentlist?rentcity="+rentcity+"&startDate="+startDate+"&endDate="+endDate+"&starthour="+starthour+"&endhour="+endhour;
					url = encodeURI(url);
					url = encodeURI(url);
					//重点步骤，转码2次，实现传参不出中文乱码或问号
					window.location.href = (url);
//					window.location.href = (basePath+"/rentindex?rentcity="+rentcity+"&startDate="+startDate+"&endDate="+endDate+"&starthour="+starthour+"&endhour="+endhour);
				};	
	});
	//房车旅行搜索跳转
	$("button.index_choosemode_two_b").click(function(){
		var linecity = $("input.index_choosemode_two_destinaton_input_input").val();
		if(linecity == ""){
			linecity = "深圳";
		};
		window.location.href = (basePath+"/linelist?linecity="+linecity);
	});
	//超级保障跳转
	$("button.index_choosemode_three_right_b").click(function(){
		window.location.href = (basePath+"/mylogin");
	});
}
//banner功能栏的选择效果,点击切换css及对应div出现
function pageBannerChoose(){
	// banner功能栏的选择效果,点击切换css及对应div出现
	$("div.index_choosemode_left>div:eq(0)").click(
			function() {
				$(this).attr("class","index_choosemode_left_item_choose");
				$("div.index_choosemode_left>div").not(this).attr("class","index_choosemode_left_item");
				$("div.index_choosemode_right>div:eq(0)").css("display", "block");
				$("div.index_choosemode_right>div").not("div.index_choosemode_right>div:eq(0)").css("display", "none");
			});
	$("div.index_choosemode_left>div:eq(1)").click(
			function() {
				$(this).attr("class","index_choosemode_left_item_choose");
				$("div.index_choosemode_left>div").not(this).attr("class","index_choosemode_left_item");
				$("div.index_choosemode_right>div:eq(1)").css("display", "block");
				$("div.index_choosemode_right>div").not("div.index_choosemode_right>div:eq(1)").css("display", "none");
			});
	$("div.index_choosemode_left>div:eq(2)").click(
			function() {
				$(this).attr("class","index_choosemode_left_item_choose");
				$("div.index_choosemode_left>div").not(this).attr("class","index_choosemode_left_item");
				$("div.index_choosemode_right>div:eq(2)").css("display", "block");
				$("div.index_choosemode_right>div").not("div.index_choosemode_right>div:eq(2)").css("display", "none");
			});
	$("div.index_choosemode_left>div:eq(3)").click(
			function() {
				$(this).attr("class","index_choosemode_left_item_choose");
				$("div.index_choosemode_left>div").not(this).attr("class","index_choosemode_left_item");
				$("div.index_choosemode_right>div:eq(3)").css("display", "block");
				$("div.index_choosemode_right>div").not("div.index_choosemode_right>div:eq(3)").css("display", "none");
			});
}
//banner房车租赁js
function pageBannerjs(){
	
	$("#chooseGocity").focus(
			function() {
				$(".index_choosemode_one_right_city").removeClass("hidden");
				$(".index_choosemode_one_right_city").focus();
			}); // 选择城市得到焦点触发
	$("#chooseBackcity").focus(
			function() {
				$(".index_choosemode_one_right_city").removeClass("hidden");
				$(".index_choosemode_one_right_city").focus();
			}); // 选择城市得到焦点触发
	$(".index_choosemode_one_right_city").blur(
			function() {
				$(".index_choosemode_one_right_city").addClass("hidden");
			}); // 选择城市失去焦点触发
}
//鼠标移动至帮助中心图片变换，字体颜色变换
function pageHelpjs(){
	var strFullPath=window.document.location.href;  
    var strPath=window.document.location.pathname;  
    var pos=strFullPath.indexOf(strPath);  
    var prePath=strFullPath.substring(0,pos);  
    var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1);  
    var basePath = prePath;  
    basePath = prePath + postPath;//获取项目根目录
    imgb=basePath+"/static/pcsofangche/index/index/";
	for (var i = 0; i < 9; i++) {
		$(".index_help_content_left_content_item:eq(" + i + ")").mouseenter(
						function(i) {
							return function(){
								$(".index_help_content_left_content_item_icon_posi:eq("+ i + ")").attr("src",imgb+"img/index_help_" + (i + 1)+ "2.png");
								$(".index_help_content_left_content_item_word:eq("+ i + ")").css("color", "#FDD000");
								console.log(i);
								console.log("地址为"+ $(".index_help_content_left_content_item_icon_posi:eq("+ i + ")")[0].src);
							}	
						}(i));
		$(".index_help_content_left_content_item:eq(" + i + ")").mouseleave(
						function(i) {
							return function(){
								$(".index_help_content_left_content_item_icon_posi:eq("+ i + ")").attr("src",imgb+"img/index_help_" + (i + 1)+ "1.png");
								$(".index_help_content_left_content_item_word:eq("+ i + ")").css("color", "#999999");
							}				
						}(i)); 
	};
}
//首页banner中房车租赁城市请求
function wantCity(type){
	$.ajax({
		dataType : "json",
		type : "post",
		url : basePath+"/carsearch",
		data : {
			type : type
		},
		contentType : "application/x-www-form-urlencoded;charset=utf-8",

		success : function(data) {
			var s = "";
			for (var i = 0; i < data.data.length; i++) {
				s = s+"<div class=\"index_choosemode_one_right_city_down_item\">"+data.data[i].city+"</div>"
					 +"<font class=\"hidden\">"+data.data[i].city+"</font>"						
				
			};
			;
			$("div.index_choosemode_one_right_city_down").html(s);
			setCity();//只有在生成结构之后才能对结构进行绑定事件
		},
		error : function() {
			console.log("访问失败");
		},
		compvare : function() {
			console.log("请求完成");
		},
	});
}
//绑定banner城市选择点击事件
function setCity(){
	var len=$("div.index_choosemode_one_right_city_down_item").length;
	for(var i=0;i<len;i++){
		$("div.index_choosemode_one_right_city_down_item:eq("+i+")").click(function(i){
			return function(){
				var city=$("div.index_choosemode_one_right_city_down>font:eq("+i+")").text();
				$("input#chooseGocity").val(city);
				$("input#chooseBackcity").val(city);
				$("div.index_choosemode_one_right_city").addClass("hidden");
			}		
		}(i))
	}
}
//绑定banner选择多少城市点击事件
function clickcity(){
	for(var i=0;i<5;i++){
		$("div.index_choosemode_one_right_city_up_three_item:eq("+i+")").click(function(i){
			return function(){
				var type=i+1;
				wantCity(type);
			}			
		}(i));
	}
}
//请求banner接口
function wantBanner(){
	$.ajax({
		dataType : "json",
		type : "get",
		url : basePath+"/bannar",
		data : {		
		},
		contentType : "application/json",

		success : function(data) {				
			for (var i = 0; i < data.data.length; i++) {
				var a=data.data[i].picture;
				var b=i+1;
				$("img#bannerimg"+b).attr("src",a);
			};
			console.log("banner")
		},
		error : function() {
			console.log("访问失败");
		},
		compvare : function() {
			console.log("请求完成");
		},
	});
}
//首页轻松租车请求
function requestRent() {
	$.ajax({
				dataType : "json",
				type : "get",
				url : basePath+"/nav",
				data : {
					type : 1
				},
				contentType : "application/x-www-form-urlencoded;charset=utf-8",

				success : function(data) {
					var s = "";
					for (var i = 0; i < data.data.length; i++) {
						s = s
								+ "<div class=\"col-lg-3 col-md-3 index_adcontent_content_item shand\" >"
								+ "<div class=\"index_adcontent_content_item_img\">"
								+ "<img src="
								+ data.data[i].picture
								+ " class=\"img-responsive\" />"
								+ "</div>"
								+ "<div class=\"index_adcontent_content_item_detail clearfix\">"
								+ "<div class=\"index_adcontent_content_item_detail_right clearfix\">"
								+ "<div class=\"index_adcontent_content_item_detail_right_three\">起</div>"
								+ "<div class=\"index_adcontent_content_item_detail_right_two\">"
								+ data.data[i].price
								+ "</div>"
								+ "<div class=\"index_adcontent_content_item_detail_right_one\">¥</div>"
								+ "</div>"
								+ "<div class=\"index_adcontent_content_item_detail_left\">"
								+ "<div class=\"index_adcontent_content_item_detail_left_city\">"
								+ data.data[i].city
								+ "</div>"
								+ "<div class=\"index_adcontent_content_item_detail_left_car\">"
								+ data.data[i].title + "</div>" + "</div>"
								+ "</div>" + "</div>"+"<font class=\"hidden\">"+data.data[i].id+"</font>";
						
					};
					;
					/* $("#img"+i).attr("src",data.data[i-1].picture); */
					$(".index_adcontent_content_ajax").html(s);
					rentGoto();//只有在生成结构之后才能对结构进行绑定事件
				},
				error : function() {
					console.log("访问失败");
				},
				compvare : function() {
					console.log("请求完成");
				},
			});

};
//点击轻松租车下面车辆信息跳转
function rentGoto(){
	if(choosetype == "轻松租车"){
		for(var i=0;i<4;i++){
			$("div.index_adcontent_content_ajax>div.index_adcontent_content_item:eq("+i+")").click(function(i){
				return function(){
					var rentcity  = $("div.index_adcontent_content_item_detail_left_city:eq("+i+")").text();
					window.location.href = (basePath+"/rentlist?rentcity="+rentcity);					
				}
			}(i));
		}
	}else{
		for(var i=0;i<4;i++){
			$("div.index_adcontent_content_ajax>div.index_adcontent_content_item:eq("+i+")").click(function(i){
				return function(){
					var lineid = $("div.index_adcontent_content_ajax>font.hidden:eq("+i+")").text();
					var linecity  = $("div.index_adcontent_content_item_detail_left_city:eq("+i+")").text();
					window.location.href = (basePath+"/lineinfo?linecity="+linecity+"&lineid="+lineid);
					console.log("lineid为"+$("div.index_adcontent_content_ajax>font.hidden:eq("+i+")").text());
				}
			}(i));
		}
	}
	
}
//首页点击轻松租车请求
function requestRentClick(){
	$("#requestRent").click(function(){
		requestRent();
		$("input.index_adhead_content_choose:eq(0)").addClass("yellowb");
		$("input.index_adhead_content_choose:eq(1)").removeClass("yellowb");
		choosetype = "轻松租车";
		console.log("轻松租车");
	});
};
//首页热门路线请求
function requestLine() {
	$.ajax({
				dataType : "json",
				type : "get",
				url : basePath+"/nav",
				data : {
					type : 2
				},
				contentType : "application/x-www-form-urlencoded;charset=utf-8",

				success : function(data) {
					console.log("66666");
					console.log("data数据" + data.data);
					console.log("data长度" + data.data.length);
					console.log(data.data[0].picture);
					var s = "";
					for (var i = 0; i < data.data.length; i++) {
						s = s
								+ "<div class=\"col-lg-3 col-md-3 index_adcontent_content_item shand\">"
								+ "<div class=\"index_adcontent_content_item_img\">"
								+ "<img src="
								+ data.data[i].picture
								+ " class=\"img-responsive\" />"
								+ "</div>"
								+ "<div class=\"index_adcontent_content_item_detail clearfix\">"
								+ "<div class=\"index_adcontent_content_item_detail_right clearfix\">"
								+ "<div class=\"index_adcontent_content_item_detail_right_three\">起</div>"
								+ "<div class=\"index_adcontent_content_item_detail_right_two\">"
								+ data.data[i].price
								+ "</div>"
								+ "<div class=\"index_adcontent_content_item_detail_right_one\">¥</div>"
								+ "</div>"
								+ "<div class=\"index_adcontent_content_item_detail_left\">"
								+ "<div class=\"index_adcontent_content_item_detail_left_city\">"
								+ data.data[i].city
								+ "</div>"
								+ "<div class=\"index_adcontent_content_item_detail_left_car\">"
								+ data.data[i].title + "</div>" + "</div>"
								+ "</div>" + "</div>"+"<font class=\"hidden\">"+data.data[i].id+"</font>";
					};
					$(".index_adcontent_content_ajax").html(s);
					rentGoto();

				},
				error : function() {
					console.log("访问失败");
				},
				compvare : function() {
					console.log("请求完成");
				},
			});

};
//首页点击热门线路请求
function requestLineClick(){
	$("#requestLine").click(function(){
		requestLine();
		console.log("热门路线");
		$("input.index_adhead_content_choose:eq(1)").addClass("yellowb");
		$("input.index_adhead_content_choose:eq(0)").removeClass("yellowb");
		choosetype = "热门线路";
		
	})
};
//请求首页国内租车城市
function requestChinacity(){
	$.ajax({
		dataType : "json",
		type : "get",
		url : basePath+"/navcity",
		data : {
			
		},
		contentType : "application/x-www-form-urlencoded;charset=utf-8",

		success : function(data) {
			var s = "";
			for (var i = 0; i < data.data.length; i++) {
				s = s+ "<div class=\"index_rentcontent_up_left\" onclick='requestChinacityinfo(\""+data.data[i].city+"\")'>"+data.data[i].city+"</div>"
			}
			;
			$(".index_rentcontent_up").prepend(s);
			

		},
		error : function() {
			console.log("访问失败");
		},
		compvare : function() {
			console.log("请求完成");
		},
	});
}
//首页国内租车深圳，广州等城市等租车信息请求
function requestChinacityinfo(chinacity){	
	$.ajax({		
		dataType : "json",
		type : "post",
		url : basePath+"/navcar",
		data : {
			city:chinacity
		},
		
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			var s = "";
			for (var i = 0; i < data.data.length; i++) {
				s = s
						+ "<div class=\"col-lg-3 col-md-3 index_adcontent_content_item shand\">"
						+ "<div class=\"index_adcontent_content_item_img\">"
						+ "<img src="
						+ data.data[i].picture
						+ " class=\"img-responsive index_adcontent_content_item_img_posi\" />"
						+ "</div>"
						+ "<div class=\"index_adcontent_content_item_detail clearfix\">"
						+ "<div class=\"index_adcontent_content_item_detail_right clearfix\">"
						+ "<div class=\"index_adcontent_content_item_detail_right_three\">起</div>"
						+ "<div class=\"index_adcontent_content_item_detail_right_two\">"
						+ data.data[i].price
						+ "</div>"
						+ "<div class=\"index_adcontent_content_item_detail_right_one\">¥</div>"
						+ "</div>"
						+ "<div class=\"index_adcontent_content_item_detail_left\">"
						+ "<div class=\"index_adcontent_content_item_detail_left_city\">"
						+ data.data[i].title
						+ "</div>"
						+ "<div class=\"index_adcontent_content_item_detail_left_car\">"
						+ data.data[i].city + "</div>" + "</div>"
						+ "</div>" + "</div>"
						+"<font class=\"hidden\">"+data.data[i].id+"</font>";
			
			}
			;
			$(".index_rentcontent_down_ajax").html(s);
			chinacityGoto();
			
			
		},
		error : function() {
			console.log("访问失败");
		},
		compvare : function() {
			console.log("请求完成");
		},
	});
}
//点击国内租车内容时候跳转绑定事件
function chinacityGoto(){
	for(var z=0;z<4;z++){
		$("div.index_rentcontent_down_ajax>div:eq("+z+")").click(function(z){
			return function(){
				var carid=$("div.index_rentcontent_down_ajax>font:eq("+z+")").text();
				var rentcity = $("div.index_rentcontent_down_ajax div.index_adcontent_content_item_detail_left_city:eq("+z+")").text();
				window.location.href = (basePath+"/rentlist?rentcity="+rentcity);	
			}		
		}(z));
	};
}
//首页经典路线点击当即热玩，面朝大海等时的请求
function wantLine(linetype){
	$.ajax({	
		dataType : "json",
		type : "post",
		url : basePath+"/navline",
		data : {
			type:linetype
		},
		
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			$("div.index_tourcontent_down_big_icon>img").attr("src",data.data[0].picture);
			$("div.index_tourcontent_down_big_title").text(data.data[0].title);
			$("div.index_tourcontent_down_big_center_right_two").text(data.data[0].price);
			$("div.index_tourcontent_down_big_center_left").text(data.data[0].city);
			var lineid="<font class=\"hidden\">"+data.data[0].city+"</font>"
			$("div.index_tourcontent_down_big").prepend(lineid);
			$("div.index_tourcontent_down_big_content").html("");
			for(var i=0;i<data.data[0].charact.length;i++){
				var charact="";
				charact=charact+"<div class=\"index_tourcontent_down_big_content_item\">"+data.data[0].charact[i].name+"</div>"			
				$("div.index_tourcontent_down_big_content").prepend(charact);
			};
			var cityinfo="";
			for (var i = 1; i < data.data.length; i++) {
				cityinfo = cityinfo
						+ "<div class=\"col-lg-4 col-md-4 index_adcontent_content_item shand\">"
						+ "<div class=\"index_adcontent_content_item_img\">"
						+ "<img src="
						+ data.data[i].picture
						+ " class=\"img-responsive\" />"
						+ "</div>"
						+ "<div class=\"index_adcontent_content_item_detail clearfix\">"
						+ "<div class=\"index_adcontent_content_item_detail_right clearfix\">"
						+ "<div class=\"index_adcontent_content_item_detail_right_three\">起</div>"
						+ "<div class=\"index_adcontent_content_item_detail_right_two\">"
						+ data.data[i].price
						+ "</div>"
						+ "<div class=\"index_adcontent_content_item_detail_right_one\">¥</div>"
						+ "</div>"
						+ "<div class=\"index_adcontent_content_item_detail_left\">"
						+ "<div class=\"index_adcontent_content_item_detail_left_city\">"
						+ data.data[i].city
						+ "</div>"
						+ "<div class=\"index_adcontent_content_item_detail_left_car\">"
						+ data.data[i].title + "</div>" + "</div>"
						+ "</div>" + "</div>"
						+"<font class=\"hidden\">"+data.data[i].id+"</font>";
			
			}
			;
			$("div.index_tourcontent_down_normal_ajax").html(cityinfo);
			lineGoto();
			
			
			
		},
		error : function() {
			console.log("访问失败");
		},
		compvare : function() {
			console.log("请求完成");
		},
	});
}
//首页经典路线点击当季热玩，面朝大海时绑定事件触发请求
function wantHotLine(){
	for(var a=0;a<4;a++){
		$("div.index_tourcontent_up_item:eq("+a+")").click(function(a){
			return function(){
				var type=$("div.index_tourcontent_up_item:eq("+a+")").data("name");
				wantLine(type);
			}		
		}(a));
	}
}
//首页点击经典路线下的内容跳转绑定事件
function lineGoto(){
	$("div.index_tourcontent_down_big").click(function(){
		var lineid = $("div.index_tourcontent_down_big>text").text();
		var linecity = $("div.index_tourcontent_down_big_center_left").text();
		var url = basePath+"/lineinfo?lineid="+lineid+"&linecity="+linecity;
		url = encodeURI(url);
		url = encodeURI(url);
		window.location.href = (url);	
	});
	for(var y=0;y<6;y++){
		$("div.index_tourcontent_down_normal_ajax>div:eq("+y+")").click(function(y){
			return function(){
				var linecity = $("div.index_tourcontent_down_normal_ajax div.index_adcontent_content_item_detail_left_city:eq("+y+")").text();
				var lineid = $("div.index_tourcontent_down_normal_ajax font:eq("+y+")").text();
				var url = basePath+"/lineinfo?lineid="+lineid+"&linecity="+linecity;
				url = encodeURI(url);
				url = encodeURI(url);
				window.location.href = (url);
			}		
		}(y));
	}
}
//更多跳转
function gotoLineIndex(){
	$("div.index_tourcontent_up_more").click(function(){
		window.location.href = (basePath+"/lineindex");
	});
	$("div.index_rentcontent_up_right").click(function(){
		window.location.href = (basePath+"/rentindex");
	});
}
//初始化出发时间返程时间
function PageLoadTime(){
$.ajax({		
		dataType : "json",
		type : "post",
		url : basePath+"/indexFormaltime",
		data : {
			
		},
		
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			var start = data.data.start;
			var end = data.data.end;
			$("input#chooseGotime").val(start);
			$("input#chooseBacktime").val(end);
		},
		error : function() {
			console.log("访问失败");
		},
		compvare : function() {
			console.log("请求完成");
		},
	});
}
//banner房车旅行栏请求城市精选
var WantHotCity = function(){
	var loading = layer.load();
	$.ajax({
		dataType : "json",
		type : "post",
		url : basePath+"/line/cityinfo",
		data : {
			
		},
		contentType : "application/x-www-form-urlencoded;charset=utf-8",

		success : function(data) {
			var a = "";
			for(var i = 0;i<data.data.datashot.length;i++){
				a = a + "<div class=\"index_choosemode_two_hot_item_item\">"+data.data.datashot[i].city+"</div>"
			};
			$("div.index_choosemode_two_hot_item").html(a);
			SearchHotCity();
			layer.close(loading);
		},
		error : function() {
			console.log("访问失败");
		},
		compvare : function() {
			console.log("请求完成");
		},
	});
}
//点击城市精选及搜索跳转绑定
var SearchHotCity = function(){
	var length = $("div.index_choosemode_two_hot_item_item").length;
	for(var i = 0;i<length;i++){
		$("div.index_choosemode_two_hot_item_item:eq("+i+")").click(function(i){
			return function(){
				var city = $("div.index_choosemode_two_hot_item_item:eq("+i+")").text();
				$("input.index_choosemode_two_destinaton_input_input").val(city);
				console.log("city="+city);
			}
		}(i))
	};
	$("button.index_choosemode_two_b").click(function(){
		var city = $("input.index_choosemode_two_destinaton_input_input").val();
		var url = basePath+"/linelist?linecity="+city;
		url = encodeURI(url);
		url = encodeURI(url);
		window.location.href = (url);
	});
}